from core.support import set_cutscene
from core.item import Item
from core.action import Action
from items.gun import Gun
import random

class Knife(Item):
    def __init__(self):
        Item.__init__(self, "knife")    # do basic initialization for every item
        
        # build list of actions
        self.add_action(Use_knife)
        
    
    def get_description(self):
        return "knife"

# define actions for this item

class Use_knife(Action):
    def __init__(self):
        Action.__init__(self, "Use knife")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Use knife"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # only works in basement. add cutscene
    def do_action(self,game,room,request):
        if room.get_id() == 'bush1':
            if room.hyena_alive:
                if random.randint(1,10)>5 :
                    set_cutscene("You killed the leopard.  You investigate the body but can't identify who it is due to the extensive damage.  Upon noticing the Iowa Hawkeyes t-shirt, you are certain that it is your friend Scott.  He looks like he was mauled to death by a lion.  You see a gun on the ground.")
                    room.hyena_alive = False
                    room.add_item(Gun())
                else:
                    set_cutscene("Thanks to your awful knife skills, all you were able to do was anger the animal.  Lucky for you, this leopard is lazy and prefers the already dead body.")
            else:
                set_cutscene("You victoriously stab the deceased leopard.")
        else:
            set_cutscene("Careful...Its all fun and games until someone loses an eye")

        return        